﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Linq;

namespace WindowsFormsApplication
{
    public partial class frmLogin : DevExpress.XtraEditors.XtraForm
    {
        qltkDb db = new qltkDb();

        public frmLogin()
        {
            InitializeComponent();
           
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            //check username and password
            var member = db.Members.SingleOrDefault(
                m => m.UserName == txtUserName.Text.Trim());

            if (member==null)
            {
                MessageBox.Show("Tài khoản không tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (member.Pass == txtPassword.Text)
            {
                this.Hide();
                var frm = new frmMain();
                frm.ShowDialog();
            }
            else
            {
                MessageBox.Show("Kiểm tra lại mật khẩu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
    }
}